package com.Lgwd.repository;

import com.Lgwd.entity.ChatKey;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @author sunchuanchuan
 * @version V1.0
 * @date 2023/3/28
 * @package com.Lgwd.repository
 * @description
 **/
@Repository
public interface ChatKeyRepository extends JpaRepository<ChatKey,Integer> {

    /**
     * 根据最后使用时间来查询数据
     * @param useDate
     * @param type
     * @return
     */
    @Query(value = "select * FROM `chat_key` where type = ?1 and status = 0 and use_date!=?2 LIMIT 1", nativeQuery = true)
    ChatKey findChatKeyByUseDate(Integer type ,Integer useDate);
}
